//priority 10000
const CuriosApi = {
    /**@returns {Internal.ItemStack}*/
    findCurios: function (/**@type {Internal.LivingEntity}*/livingEntity,/**@type {Internal.Item}*/ Item) {
        var targetStack
        livingEntity.getCapability(CuriosCapabilities.INVENTORY).ifPresent((handler) => {
            var iterator = handler.curios.values().iterator()
            while (iterator.hasNext() && targetStack == null) {
                for (const itemstack of iterator.next().getStacks().getAllItems()) {
                    if (itemstack.getItem() == Item) {
                        targetStack = itemstack
                        break
                    }
                }
            }
        })
        return targetStack
    },
    getAllCuriosTags: function (/**@type {Internal.LivingEntity}*/livingEntity) {
        var Array = Utils.newList()
        livingEntity.getCapability(CuriosCapabilities.INVENTORY).ifPresent((handler) => {
            handler.curios.forEach((_, stacksHandler) => {
                stacksHandler.stacks.getAllItems().forEach(itemstack => {
                    itemstack.tags.toArray().forEach(tag => {
                        if (!Array.contains(tag.location())) {
                            Array.push(tag.location())
                        }
                    })
                })
            })
        })
        return Array
    }
}